package com.jacobson.huobi.mvp.adapters

import android.content.Context
import android.view.ViewGroup
import com.jacobson.core.widget.adapter.ListRecyclerAdapter
import com.jacobson.huobi.R
import com.jacobson.huobi.components.CommonListRecyclerAdapter
import com.jacobson.huobi.entities.InviteUserInfo
import kotlinx.android.synthetic.main.item_invite_user_info.view.*
import javax.inject.Inject
import javax.inject.Named

class InviteUserListAdapter @Inject constructor(@Named("context") context: Context) :
    CommonListRecyclerAdapter<InviteUserInfo>(context) {

    override fun onCreateContentViewHolder(
        parent: ViewGroup,
        viewType: Int
    ): ContentViewHolder<InviteUserInfo> {
        return ViewHolder(context, parent)
    }

    class ViewHolder(
        context: Context?,
        parent: ViewGroup
    ) : ListRecyclerAdapter.ContentViewHolder<InviteUserInfo>(
        context,
        parent,
        R.layout.item_invite_user_info
    ) {

        override fun onBindView(
            items: List<InviteUserInfo>,
            item: InviteUserInfo,
            position: Int
        ) {
            with(itemView) {
                tvInviteUserPhone.text = item.inviteUserTelephone
                when(item.vipStatus) {
                    0 -> tvInviteUserState.text = "无效的"
                    1 -> tvInviteUserState.text = "有效的"
                    2 -> tvInviteUserState.text = "过期的"
                    3 -> tvInviteUserState.text = "编辑中"
                    4 -> tvInviteUserState.text = "待审核"
                    5 -> tvInviteUserState.text = "审核通过"
                    6 -> tvInviteUserState.text = "审核拒绝"
                }
                if (item.settlementStatus) {
                    tvInviteUserReward.text = item.commission.toString()
                } else {
                    tvInviteUserReward.text = "无"
                }
                tvInviteUserDate.text = item.rechargeTime
            }
        }
    }
}